package com.sinodata.bsm.center.web.action.appview;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;

import com.sinodata.bsm.center.bean.Page;
import com.sinodata.bsm.center.bean.ResBean;
import com.sinodata.bsm.center.cache.PropertyCache;
import com.sinodata.bsm.center.service.performance.PropValueService;
import com.sinodata.bsm.center.util.web.Struts2Utils;
import com.sinodata.bsm.center.web.action.BaseAction;
import com.sinodata.bsm.center.web.action.performance.DateGeneric;
import com.sinodata.bsm.common.utils.DoubleUtil;
import com.sinodata.bsm.common.utils.StringUtil;
import com.sinodata.bsm.common.vo.Property;
import com.sinodata.bsm.common.vo.PropertyValue;

import edu.emory.mathcs.backport.java.util.LinkedList;

public class ResAnalysisAction extends BaseAction {

    private Long id;
    @Autowired
    private PropertyCache propertyCache;
    @Autowired
    private PropValueService propService;

    private final SimpleDateFormat daySdf = new SimpleDateFormat("yyyy-MM-dd");
    private static int BEGIN_YEAR = 2000;

    /**
     * 进入单个服务分析页面
     */
    public String view() {
        int nowYear = Calendar.getInstance().get(Calendar.YEAR);
        List yearList = new LinkedList();
        for (int i = nowYear; i >= BEGIN_YEAR; i--) {
            yearList.add("" + i);
        }
        List monthList = new LinkedList();
        for (int i = 1; i <= 12; i++) {
            monthList.add("" + i);
        }
        Struts2Utils.setRequestAttribute("monthList", monthList);
        Struts2Utils.setRequestAttribute("yearList", yearList);
        return SUCCESS;
    }

    /**
     * 元素方差计算(同比和环比)
     * 
     * @return
     */
    public String queryPropertyVar() {
        try {
            String resId = request.getParameter("resId");
            String propId = request.getParameter("propId");
            String beginDate = request.getParameter("beginDate");
            String endDate = request.getParameter("endDate");
            String choiceDate = request.getParameter("choiceDate");
            String choiceType = "1";
            //暂定两个数据
            beginDate = "2013-05-16";
            choiceDate = "day";
            //			if (!"day".equals(choiceDate))
            //				choiceType = "2";
            resId = "14100";
            propId = "110506000000001";
            if (!resId.equals("14100"))
                resId = "14100";
            String[] props = new String[1];
            props[0] = propId;
            int[] propids = new int[props.length];
            for (int i = 0; i < props.length; i++) {
                Property p = propertyCache.get(Long.parseLong(props[i]));
                int ii = p.getStore();
                propids[i] = ii;
            }
            List<PropertyValue> proList = propService.getPropValValueList(Long.valueOf(resId), propids, beginDate, endDate, choiceType);
            JSONObject columnJson = buildVarJsonColumn("方差同比与环比图", proList);
            Struts2Utils.renderText(columnJson.toString());
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }
        return null;
    }

    public String queryMaxPropertyValue() {
        try {
            String resId = request.getParameter("resId");
            String propId = request.getParameter("propId");
            String beginDate = request.getParameter("beginDate");
            String endDate = request.getParameter("endDate");
            String choiceDate = request.getParameter("choiceDate");
            if (StringUtil.isEmpty(endDate))
                endDate = DateGeneric.getMonthEnd(beginDate);
            if ("day".equals(choiceDate)) {
                endDate = beginDate + " 23:59:59";
                beginDate += " 00:00:00";
            }
            resId = "14100";
            propId = "110506000000001";
            JSONObject json = new JSONObject();
            if (!resId.equals("14100"))
                resId = "14100";
            String[] props = new String[1];
            props[0] = propId;
            int[] propids = new int[props.length];
            for (int i = 0; i < props.length; i++) {
                Property p = propertyCache.get(Long.parseLong(props[i]));
                int ii = p.getStore();
                propids[i] = ii;
            }
            String maxValue = propService.queryMaxPropValueByDate(Long.valueOf(resId), propids, beginDate, endDate);
            json.element("maxValue", maxValue != null ? maxValue : 0);
            Struts2Utils.renderText(json.toString());
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 响应时间分布图
     * @return
     */
    public String queryPropertyDistribution() {
        try {
            String resId = request.getParameter("resId");
            String propId = request.getParameter("propId");
            String beginDate = request.getParameter("beginDate");
            String spaceTime = request.getParameter("spaceTime");
            String endDate = request.getParameter("endDate");
            String choiceDate = request.getParameter("choiceDate");
            if (StringUtil.isEmpty(endDate))
                endDate = DateGeneric.getMonthEnd(beginDate);
            if ("day".equals(choiceDate)) {
                endDate = beginDate + " 23:59:59";
                beginDate += " 00:00:00";
            }
            resId = "14100";
            propId = "110506000000001";
            List<String> spaceTimeList = new java.util.LinkedList<String>();
            if (StringUtil.isEmpty(spaceTime)) {
                spaceTime = "100#200";
            }
            // 将指定的秒数分割
            if (!StringUtil.isEmpty(spaceTime)) {
                String[] spaceTimeArray = spaceTime.split(",");
                if (spaceTimeArray != null && spaceTimeArray.length > 0) {
                    for (int i = 0; i < spaceTimeArray.length; i++) {
                        spaceTimeList.add(spaceTimeArray[i]);
                    }
                }
            }
            JSONObject json = new JSONObject();
            if (!resId.equals("14100"))
                resId = "14100";
            String[] props = new String[1];
            props[0] = propId;
            int[] propids = new int[props.length];
            for (int i = 0; i < props.length; i++) {
                Property p = propertyCache.get(Long.parseLong(props[i]));
                int ii = p.getStore();
                propids[i] = ii;
            }
            Map<String, String> propertyValueMap = propService.getCountPropValuesBySpace(Long.parseLong(resId), propids, beginDate, endDate, "0", spaceTimeList);
            // String jsonLinear = buoldLinearGauge();
            String pieTitle = buildPieTitle(resId, beginDate, endDate);
            JSONObject piejson = buildJsonPie(pieTitle.toString(), propertyValueMap);
            json.element("pieData", piejson);
            // json.element("linearData", jsonLinear);
            Struts2Utils.renderText(json.toString());
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 同比和环比
     * @return
     */
    public String queryResCompareProp() {
        try {
            // 页面参数获取
            String choiceType = request.getParameter("choiceType");
            String resId = request.getParameter("resId");
            String propId = request.getParameter("propId");
            String beginDate = request.getParameter("beginDate");
            String choiceDate = request.getParameter("choiceDate");
            String endDate = null;
            String dime = "2";
            resId = "14100";
            propId = "110506000000001";
            if (StringUtil.isEmpty(endDate))
                endDate = DateGeneric.getMonthEnd(beginDate);
            if ("day".equals(choiceDate)) {
                endDate = beginDate + " 23:59:59";
                beginDate += " 00:00:00";
                dime = "1";

            }
            if (!resId.equals("14100"))
                resId = "14100";
            String[] props = new String[1];
            props[0] = propId;
            int[] propids = new int[props.length];
            for (int i = 0; i < props.length; i++) {
                Property p = propertyCache.get(Long.parseLong(props[i]));
                int ii = p.getStore();
                propids[i] = ii;
            }
            JSONObject json = new JSONObject();
            // 图标的JSON
            JSONObject jsonObject = new JSONObject();
            // 同比
            List<PropertyValue> propertyList = propService.getThrendComparePropvalus(Long.valueOf(resId), propids, beginDate, endDate, "0", dime, choiceType);
            Calendar begincalendar = DateGeneric.switchStringToCalendar(beginDate);
            // 将数据封装
            Map<String, PropertyValue> compareMap = new HashMap<String, PropertyValue>();
            Map<String, PropertyValue> currenMap = new HashMap<String, PropertyValue>();
            String currenLabel = "";
            String compareLabel = "";
            if (propertyList != null) {
                for (PropertyValue pv : propertyList) {
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTime(pv.getTime());
                    int year = calendar.get(Calendar.YEAR);
                    int month = calendar.get(Calendar.MONTH);
                    String day = String.valueOf(pv.getTime().getDate());
                    String hour = String.valueOf(pv.getTime().getHours());
                    // 同比
                    // 月的同比 将天当作Key
                    if (choiceDate.equals("month")) {
                        if (year == begincalendar.get(Calendar.YEAR) && month == begincalendar.get(Calendar.MONTH)) {
                            currenMap.put(day, pv);
                            if (StringUtil.isEmpty(currenLabel)) {
                                currenLabel = String.valueOf(year) + "-" + String.valueOf(month + 1);
                            }
                        } else {
                            compareMap.put(day, pv);
                            if (StringUtil.isEmpty(currenLabel)) {
                                compareLabel = String.valueOf(year) + "-" + String.valueOf(month + 1);
                            }
                        }
                    }
                    if (choiceDate.equals("day")) {
                        if (year == begincalendar.get(Calendar.YEAR) && month == begincalendar.get(Calendar.MONTH)) {
                            currenMap.put(hour, pv);
                            currenLabel = String.valueOf(year) + "-" + String.valueOf(month + 1) + "-" + day;
                        } else {
                            compareMap.put(hour, pv);
                            compareLabel = String.valueOf(year) + "-" + String.valueOf(month + 1) + "-" + day;
                        }
                    }

                }
                List<String> lableLinkList = new java.util.LinkedList<String>();
                int index = "day".equals(choiceDate) ? 24 : 31;
                for (int i = 1; i <= index; i++) {
                    lableLinkList.add(String.valueOf(i));
                }
                String title = buildLineTitle(resId, beginDate, endDate, choiceType, "0");
                jsonObject = buildJsonCompareLine(title, compareMap, currenMap, lableLinkList, currenLabel, compareLabel);
                json.element("lineData", jsonObject);
                json.element("beginDate", beginDate);
                json.element("endDate", endDate);
                Struts2Utils.renderText(json.toString());
            }
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 饼图的标题
     * @param resId
     * @param beginDate
     * @param endDate
     * @return
     */
    private String buildPieTitle(String resId, String beginDate, String endDate) {
        StringBuffer pieBuffer = new StringBuffer();
        pieBuffer.append("[资源：");
        pieBuffer.append(ResBean.get(Long.parseLong(resId)).res().getName() + "]  [时间：");
        pieBuffer.append(beginDate);
        pieBuffer.append(" -- ");
        pieBuffer.append(endDate);
        pieBuffer.append("]原数据分布图");
        return pieBuffer.toString();
    }

    /**
     * 曲线图的标题
     * @param resId
     *            资源ID
     * @param timeSection
     *            时间范围
     * @param beginDate
     *            开始日期
     * @param endDate
     *            结束日期
     * @param trendtype
     *            趋势类型
     * @param dimen
     *            数据维度
     * @return
     */
    private String buildLineTitle(String resId, String beginDate, String endDate, String choiceType, String dimen) {
        StringBuilder sb = new StringBuilder("[");
        try {
            if ("1".equals(dimen)) {
                sb.append("时汇聚-");
            } else {
                sb.append("日汇聚-");
            }
            sb.append("0".equals(choiceType) ? "普通分析" : "1".equals(choiceType) ? "同比分析" : "2".equals(choiceType) ? "环比分析" : "普通分析");
            sb.append("[资源：");
            sb.append(ResBean.get(Long.parseLong(resId)).res().getName() + "]  [时间：");
            sb.append(beginDate);
            sb.append(" -- ");
            sb.append(endDate);
            sb.append("]");
        } catch (Exception e) {
            logger.error(e.getMessage());
        }
        return sb.toString();
    }

    /**
     * 分析某个资源下的指标的最大、最小、平均趋势图
     * @return
     */
    @SuppressWarnings("unchecked")
    public String queryResProp() {
        try {
            String resId = request.getParameter("resId");
            if (!resId.equals("14100"))
                resId = "14100";
            String dimen = request.getParameter("dimen");
            String propId = request.getParameter("propId");
            // 暂定为指标为响应时长
            propId = "110506000000001";
            String timeSection = request.getParameter("timeSection");
            String beginDate = request.getParameter("beginDate");
            String endDate = request.getParameter("endDate");
            String[] props = new String[1];
            props[0] = propId;
            int[] propids = new int[props.length];
            for (int i = 0; i < props.length; i++) {
                Property p = propertyCache.get(Long.parseLong(props[i]));
                int ii = p.getStore();
                propids[i] = ii;
            }
            if (dimen == null || dimen.length() == 0) {
                dimen = "0";
            }
            Page<PropertyValue> page = new Page<PropertyValue>();
            page.setPageNo(Integer.valueOf(request.getParameter("iDisplayStart")) / Integer.valueOf(request.getParameter("iDisplayLength")) + 1);
            page.setPageSize(Integer.valueOf(request.getParameter("iDisplayLength")));
            JSONObject json = new JSONObject();
            // 表格JSON
            JSONArray propArray = new JSONArray();
            // 普通查询的情况
            // 图标的JSON
            JSONObject jsonObject = new JSONObject();
            // 普通查询，构建avg、Max、min三值得曲线图
            beginDate = DateGeneric.genericStartDate(timeSection, beginDate);
            endDate = DateGeneric.getnericEndDate(dimen, timeSection, endDate);
            page = propService.getPropValuesByPage(Long.parseLong(resId), page, propids, beginDate, endDate, dimen);
            List<PropertyValue> list = page.getRows();
            for (PropertyValue pv : list) {
                JSONObject obj = new JSONObject();
                String formateTime = formateDate(pv.getTime(), timeSection);
                obj.element("time", formateTime);
                for (int i = 0; i < propids.length; i++) {
                    obj.element("avg", pv.getValues()[4 * i] == null ? "&nbsp;" : pv.getValues()[4 * i]);
                    obj.element("max", pv.getValues()[4 * i + 2] == null ? "&nbsp;" : pv.getValues()[4 * i + 2]);
                    obj.element("min", pv.getValues()[4 * i + 3] == null ? "&nbsp;" : pv.getValues()[4 * i + 3]);
                }

                propArray.add(obj);
            }
            List<PropertyValue> propertyValueLineList = propService.getPropValues(Long.parseLong(resId), propids, beginDate, endDate, dimen);
            String lineTitle = buildLineTitle(resId, beginDate, endDate, "0", dimen);
            jsonObject = buildJsonLine(lineTitle, propertyValueLineList);
            json.element("lineData", jsonObject);
            // 构建原始数据的饼状图
            json.element("aaData", propArray);
            json.element("iTotalRecords", page.getTotal());
            json.element("iTotalDisplayRecords", page.getTotal());
            json.element("beginDate", beginDate);
            json.element("endDate", endDate);
            Struts2Utils.renderText(json.toString());
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 饼图Json计算
     * @param title
     * @param map
     * @return
     */
    private JSONObject buildJsonPie(String title, Map<String, String> map) {
        // 根据数字分值计算
        JSONObject json = new JSONObject();
        JSONObject chart = new JSONObject();
        JSONArray datajson = new JSONArray();

        chart.element("showvalues", "1");
        chart.element("caption", title);

        chart.element("showpercentvalues", "1");

        chart.element("showlegend", "1");

        chart.element("showlabels", "0");

        chart.element("legendPosition", "right");
        chart.element("legendIconScale", "2");
        chart.element("bgColor", "ffffff");
        chart.element("showBorder", "0");

        chart.element("showpercentageinlabel", "1");
        if (map.get("count") != null) {
            double b = Double.valueOf(map.get("count"));
            Iterator iterator = map.entrySet().iterator();
            while (iterator.hasNext()) {
                Entry<String, String> entry = (Entry<String, String>) iterator.next();
                if ("count".equals(entry.getKey())) {
                    continue;
                }
                JSONObject downhundredjson = new JSONObject();
                downhundredjson.element("label", entry.getKey());
                double a = entry.getValue() != null ? Double.valueOf(entry.getValue()) : 0;
                if (b > 0) {
                    downhundredjson.element("value", DoubleUtil.padDoubleLeft(a * 100 / b, 50, 2));
                }
                datajson.add(downhundredjson);
            }
        }
        json.element("chart", chart);
        json.element("data", datajson);
        return json;
    }

    /**
     * 同比和环比曲线图
     * 
     * @param title
     * @param compareMap
     * @param currenMap
     * @param timeSet
     * @return
     */
    private JSONObject buildJsonCompareLine(String title, Map<String, PropertyValue> compareMap, Map<String, PropertyValue> currenMap, List<String> lableLinkList, String currenLable, String compareLable) {
        JSONObject json = new JSONObject();
        try {
            JSONObject chart = buildJsonLineChart(title);
            int step = lableLinkList.size() / 10 + 1;
            chart.element("labelStep", step);
            JSONArray jj = new JSONArray();
            JSONObject o = new JSONObject();
            // 处理X轴的值
            JSONArray labelJson = new JSONArray();
            String labelText = lableLinkList.size() > 24 ? "日" : "时";
            for (String lable : lableLinkList) {
                JSONObject obj = new JSONObject();
                obj.element("label", lable + labelText);
                labelJson.add(obj);
            }
            o.element("category", labelJson);
            jj.add(o);
            // 处理数据集
            JSONArray dataset = new JSONArray();
            // 当前期
            JSONObject currenJson = new JSONObject();
            JSONArray currenArray = new JSONArray();
            currenJson.element("seriesname", currenLable);
            currenJson.element("renderas", "Line");
            currenJson.element("parentyaxis", "s");
            // 最大
            JSONObject compareJson = new JSONObject();
            JSONArray compareArray = new JSONArray();
            compareJson.element("seriesname", compareLable);
            compareJson.element("renderas", "Area");
            compareJson.element("parentyaxis", "P");
            for (String time : lableLinkList) {
                JSONObject currenObject = new JSONObject();
                JSONObject compareObject = new JSONObject();

                if (compareMap.get(time) != null)
                    compareObject.element("value", compareMap.get(time) != null ? compareMap.get(time).getValues()[0] : null);
                if (currenMap.get(time) != null)
                    currenObject.element("value", currenMap.get(time) != null ? currenMap.get(time).getValues()[0] : null);
                currenArray.add(currenObject);
                compareArray.add(compareObject);
            }
            currenJson.element("data", currenArray);
            compareJson.element("data", compareArray);
            dataset.add(currenJson);
            dataset.add(compareJson);
            // 封装数据完成
            json.element("chart", chart);
            json.element("categories", jj);
            json.element("dataset", dataset);
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }
        return json;
    }

    /**
     * 构建方差的柱状图
     * @param list
     * @return
     */
    private JSONObject buildVarJsonColumn(String title, List<PropertyValue> list) {
        JSONObject json = new JSONObject();
        JSONObject chart = new JSONObject();
        chart.element("showborder", "0");
        chart.element("bgcolor", "FFFFFF,FFFFFF");
        chart.element("useroundedges", "1");
        chart.element("caption", title);
        JSONArray dataJsonArray = new JSONArray();
        for (PropertyValue p : list) {
            JSONObject jsonObject = new JSONObject();
            jsonObject.element("value", p.getValues()[0]);
            jsonObject.element("label", daySdf.format(p.getTime()));
            dataJsonArray.add(jsonObject);
        }
        json.element("chart", chart);
        json.element("data", dataJsonArray);
        return json;

    }

    /**
     * 普通分析、同比、环比chart对象的构建
     * @param title
     * @return
     */
    private JSONObject buildJsonLineChart(String title) {
        JSONObject chart = new JSONObject();
        chart.element("numvdivlines", "22");
        chart.element("showvalues", "0");
        chart.element("caption", title);
        chart.element("animation", "1");
        chart.element("legendPosition", "right");
        chart.element("legendIconScale", "2");
        chart.element("divlinedecimalprecision", "1");
        chart.element("limitsdecimalprecision", "0");
        chart.element("anchoralpha", "100");
        chart.element("showalternatevgridcolor", "1");
        chart.element("anchorbgalpha", "50");
        chart.element("anchorradius", "2");
        chart.element("slantlabels", "1");
        chart.element("labeldisplay", "ROTATE");
        chart.element("linethickness", "2");
        chart.element("numdivlines", "9");
        chart.element("bgSWFAlpha", "0");
        chart.element("showBorder", "0");
        chart.element("formatNumberScale", "1");
        chart.element("canvasBorderThickness", "0");
        chart.element("canvasBorderColor", "000000");
        chart.element("divLineThickness", "1");
        chart.element("vDivLineThickness", "1");
        chart.element("alternateVGridColor", "ffffff");
        chart.element("divLineColor", "cccccc");
        chart.element("canvasBgAlpha", "100");
        chart.element("canvasBgColor", "ffffff");
        chart.element("bgColor", "ffffff");
        chart.element("vDivLineColor", "e5e3e3");
        chart.element("alternateHGridColor", "ffffff");
        chart.element("legendPosition", "right");
        chart.element("anchorBgColor", "ffffff");
        chart.element("bgAlpha", "0");
        chart.element("interactiveLegend", "1");
        return chart;
    }

    /**
     * 构建普通分析的曲线图
     * 
     * @return
     */
    private JSONObject buildJsonLine(String title, List<PropertyValue> list) {
        JSONObject json = new JSONObject();
        JSONObject chart = buildJsonLineChart(title);
        int step = list.size() / 10 + 1;
        chart.element("labelStep", step);

        JSONArray jj = new JSONArray();
        JSONObject o = new JSONObject();
        // 处理X轴的值
        JSONArray labelJson = new JSONArray();
        for (PropertyValue p : list) {
            JSONObject obj = new JSONObject();
            obj.element("label", daySdf.format(p.getTime()));
            labelJson.add(obj);
        }
        o.element("category", labelJson);
        jj.add(o);

        // 处理数据集
        JSONArray dataset = new JSONArray();
        // 平均
        JSONObject avgJson = new JSONObject();
        JSONArray avgArray = new JSONArray();
        avgJson.element("seriesname", "avg");
        avgJson.element("color", "0000ff");
        avgJson.element("anchorBorderColor", "0080C0");

        // 最大
        JSONObject maxJson = new JSONObject();
        JSONArray maxArray = new JSONArray();
        maxJson.element("seriesname", "max");
        maxJson.element("color", "00ff00");
        maxJson.element("anchorBorderColor", "008040");

        // 最小
        JSONObject minJson = new JSONObject();
        JSONArray minArray = new JSONArray();
        minJson.element("seriesname", "min");
        minJson.element("color", "ff0000");
        minJson.element("anchorBorderColor", "808080");

        int index = 0;
        for (PropertyValue pv : list) {
            JSONObject avgObject = new JSONObject();
            JSONObject maxObject = new JSONObject();
            JSONObject minObject = new JSONObject();
            avgObject.element("value", pv.getValues()[4 * index] == null ? "&nbsp;" : pv.getValues()[4 * index]);
            maxObject.element("value", pv.getValues()[4 * index + 2] == null ? "&nbsp;" : pv.getValues()[4 * index + 2]);
            minObject.element("value", pv.getValues()[4 * index + 3] == null ? "&nbsp;" : pv.getValues()[4 * index + 3]);
            avgArray.add(avgObject);
            maxArray.add(maxObject);
            minArray.add(minObject);
        }
        minJson.element("data", minArray);
        maxJson.element("data", maxArray);
        avgJson.element("data", avgArray);
        dataset.add(minJson);
        dataset.add(maxJson);
        dataset.add(avgJson);
        // 封装数据完成
        json.element("chart", chart);
        json.element("categories", jj);
        json.element("dataset", dataset);

        return json;
    }

    /**
     * 
     * demo:2012-08-23 17:13:27.0
     * 
     * @param d
     * @param timeSection
     * @return
     */
    private String formateDate(Date d, String timeSection) {
        return d.toString().replaceAll("-", "/").substring(5, d.toString().length() - 2);
    }

    @Override
    public String delete() throws Exception {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public String input() throws Exception {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public String list() throws Exception {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    protected void prepareModel() throws Exception {
        // TODO Auto-generated method stub

    }

    @Override
    public String save() throws Exception {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public Object getModel() {
        // TODO Auto-generated method stub
        return null;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

}
